<%--
  Created by IntelliJ IDEA.
  User: asus
  Date: 2022/10/28
  Time: 22:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>个人资料</title>
    <link type="text/css" href="css/idea.css" rel="stylesheet" />
    <link type="text/css" href="css/user_home.css" rel="stylesheet" />
    <link type="text/css" href="css/common.css" rel="stylesheet" />
    <link type="text/css" href="css/reset.css" rel="stylesheet" />
    <link rel="shortcut icon" type="image/x-icon" href="images/nangua.jpg" media="screen" />
    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script><!--必须得放在第一的位置-->
    <script type="text/javascript" src="js/index_type_more.js"></script>
    <script type="text/javascript" src="js/index_main_pic.js"></script>

    <script type="text/javascript" src="js/user_home.js"></script>
</head>

<body>
<script type="text/javascript">
    $(document).ready(function (){
        order();
        mysellcar();
        wantsell();
        myCollection();
        favoritenum();
        reservenum();
    })
</script>
<script>
    function order() {
        $.ajax({
            url:"getOrderByUserId.do",
            type:"GET",
            //data:{page:page,size:size},
            dataType:"json",
            success:function (msg) {
                if(msg.flag==1){
                    $("#orderlist").html(msg.data.allCount);
                }
            }
        });
    }

    function mysellcar() {
        $.ajax({
            url:"getCarByUserId.do",
            type:"GET",
            //data:{page:page,size:size},
            dataType:"json",
            success:function (msg) {
                if(msg.flag==1){
                    $("#sellcarnum").html(msg.data.allCount);
                }
            }
        });
    }
    function wantsell() {
        $.ajax({
            url:"getWantSellListByUserIdOfPage.do",
            type:"GET",
            //data:{page:page,size:size},
            dataType:"json",
            success:function (msg) {
                if(msg.flag==1){
                    $("#wantsell").html(msg.data.allCount);//分页
                }
            }
        });
    }

    function myCollection() {
        $.ajax({
            url:"getCollectionByUserId.do",
            type:"GET",
            //data:{page:page,size:size},
            dataType:"json",
            success:function (msg) {
                if(msg.flag==1){
                    $("#collectionnum").html(msg.data.allCount);
                }
            }
        });
    }

    function favoritenum() {
        $.ajax({
            url:"getPushListByUserId.do",
            type:"GET",
            //data:{page:page,size:size},
            dataType:"json",
            success:function (msg) {
                if(msg.flag==1){
                    $("#favoritenum").html(msg.data.allCount);//全部想要
                }
            }
        });
    }

    function reservenum() {
        $.ajax({
            url:"getReserveByUserId.do",
            type:"GET",
            //data:{page:page,size:size},
            dataType:"json",
            success:function (msg) {
                if(msg.flag==1){
                    $("#reservenum").html(msg.data.allCount);
                }
            }
        });
    }
</script>
<script>
    function getLength(str){
        if (str == null) return 0;
        /*if (typeof str != "string"){
           str += "";
        } */
        return str.replace(/[^\x00-\xff]/g,"01").length;
    }
    //检查 全部
    function checkall(){
        if(check1() == true && check2() == true && check4() == true && check5()){
            return true;
        }return false;
    }

    function check1(t){
        /*用户名账号*/
        var user_name=$(".user_name_");
            var len=getLength(t.value);
            var reg=/^[a-zA-Z][a-zA-Z0-9_]{5,24}$/;
            //不能为空
            if(t.value==""){

                $('.user_name_ms').html('<i class="fail_fa"></i>用户名不能为空。');
                user_name.val("");

            }
            //长度小于5个字符
            else if(len<6){
                $('.user_name_ms').html('<i class="fail_fa"></i>长度小6个字符。');
                user_name.val("");
            }
            //长度超过25个字符
            else if(len>25){
                $('.user_name_ms').html('<i class="fail_fa"></i>长度超过25个字符。');
                user_name.val("");
            }
            //含有非法字符
            else if(!reg.test(t.value)){
                $('.user_name_ms').html('<i class="fail_fa"></i>用户名格式不对。');
                user_name.val("");
            }
            //验证成功
            else{
                $('.user_name_ms').html('<i class="succeed_su"></i>验证成功。');
            }
    }

    function check2(t){
        /*手机号*/
        var mobile=$(".mobile_");

            //含有非法字符
            /*var emai=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
            var phon=/^1[3|4|5|8][0-9]\d{4,8}$/;
            if(!emai.test(this.value)||!phon.test(this.value))*//*这样不可以*/
            var pho=/^1[3|4|5|8][0-9]\d{4,8}$/;
            if(t.value==""){
                $('.mobile_ms').html('<i class="fail_fa"></i>手机号不能为空。');
                mobile.val("");
            }else if(!pho.test(t.value)){
                $('.mobile_ms').html('<i class="fail_fa"></i>手机号格式不正确。');
                mobile.val("");
                //验证成功
            }else{
                $('.mobile_ms').html('<i class="succeed_su"></i>验证成功。');
                return true;
            }
    }

    function check3(t){
        /*密码*/
        var user_ps=$(".user_ps_");
            //含有非法字符
            /*var len=getLength(this.value);
            var reg=user_ps.val().match(/^\w+$/);*/

            if(t.value==""){
                $('.user_ps_ms').html('<i class="fail_fa"></i>密码不能为空。');
                return false;
            }else if(!(/^[A-Za-z0-9_]{6,18}$/).test(t.value)){
                $('.user_ps_ms').html('<i class="fail_fa"></i>密码只能是6到18位数字、下划线、字母。');
                return false;
            }
            //验证成功
            else{
                $('.user_ps_ms').html('<i class="succeed_su"></i>验证成功。');
                return true;
            }
    }

    function check4(t){
        /*确认密码*/
        var user_ps1=$(".user_ps1_");
        var user_ps=$(".user_ps_");
            if(t.value==""){
                $('.user_ps1_ms').html('<i class="fail_fa"></i>新密码不能为空。');
                user_ps1.val("");
            }else if(user_ps1.val()!=user_ps.val()){
                $('.user_ps1_ms').html('<i class="fail_fa"></i>密码不一致。');
                user_ps1.val("");
            }else{
                $('.user_ps1_ms').html('<i class="succeed_su"></i>验证成功。');
                return true;
            }
    }

    function check5(t){
        /*身份证号*/
        var id_number=$(".id_number_")
            //含有非法字符

            var p =/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/;
            if(t.value==""){
                $('.id_number_ms').html('<i class="fail_fa"></i>身份证号不能为空');
                id_number.val("");
            }
            else if(!p.test(t.value)){
                $('.id_number_ms').html('<i class="fail_fa"></i>身份证号格式不对。');
                id_number.val("");
            }else{
                $('.id_number_ms').html('<i class="succeed_su"></i>验证成功。');
            }
    }
</script>
<div class="index">

    <!--头部导航-->
    <jsp:include page="head.jsp"></jsp:include>
    <!--头部导航结束-->

    <div class="hr_5"></div>
    <div class="user_content f_f width_1200_center">
        <div class="content_position">您当前的位置：<a href="index.jsp">首页</a><span>&gt;</span><a href="userhome.jsp">个人中心</a><span>&gt;</span><a href="userhome.jsp">个人资料</a></div>
        <!-- <div class="user_content_top f_z15"><a href="#">注册会员</a><span>Register</span></div>-->
        <div class="hr_10"></div>
        <div class="user_content_con over_hidden width_1200_center"><!--over_hidden也是清除浮动的一种-->
            <div class="user_content_con_nav fl" style="height: 400px">

                <div class="nav_info">
                    <h1>个人信息</h1>
                    <ul>
                        <li><a href="userhome.jsp">个人资料</a></li>
                        <li><a href="#">收货地址</a></li>
                        <li><a href="#">安全设置</a></li>
                    </ul>
                </div>
                <div class="nav_goods">
                    <h1>商品管理</h1>
                    <ul>
                        <li><a href="order.jsp">我的订单</a></li>
                        <li><a href="mycar.jsp">我卖的车</a></li>
                        <li><a href="mywantsellcar.jsp">卖车预约</a></li>
                        <li><a href="myfavorite.jsp">我想要的</a></li>
                        <li><a href="mycollection.jsp">我的收藏</a></li>
                        <li><a href="myreserve.jsp">看车预约</a></li>
                    </ul>
                </div>

            </div>
            <!--右侧信息开始-->
            <div class="user_content_con_c fr">
                <div class="user_home f_f width_1000_center">
                    <div class="user_home_top over_hidden">
                        <div class="left fl"></div>
                        <div class="right_name fl"><p class="p1">欢迎用户：${sessionScope.loginuser.user_name}</p><p class="p2 p3"><span>账号安全：</span><span class="span1"><span class="span2"></span></span><span class="span3">较高</span></p></div>
                    </div><!--top完-->
                    <div class="user_home_content width_1000_center clearfix">
                        <div class="fl"><a href="order.jsp">我的订单<span class="span1" id="orderlist"></span></a></div>
                        <div class="fl"><a href="mycar.jsp">我卖的车<span class="span1" id="sellcarnum"></span></a></div>
                        <div class="fl"><a href="mywantsellcar.jsp">卖车预约<span class="span1" id="wantsell">4</span></a></div>
                        <div class="fl"><a href="myfavorite.jsp">我想要的<span class="span1" id="favoritenum">4</span></a></div>
                        <div class="fl"><a href="mycollection.jsp">我的收藏<span class="span1" id="collectionnum"></span></a></div>
                        <div class="fl"><a href="myreserve.jsp">看车预约<span class="span1" id="reservenum"></span></a></div>
                    </div>
                    <div class="hr_10"></div>
                    <div class="content_goods_cart_top over_hidden width_1000_center">
                        <div class="top_cart fl"><h1>我的信息</h1></div>
                        <div class="top_all fr"><span class="span1"></span></div>
                    </div>
                    <br>
                    <form action="updateUser.do" onsubmit="checkall()">
                        <input type="hidden" value="${loginuser.user_id}" name="user_id">
                        <div class="con_4 over_hidden" >
                            <th class="name1">用户名：</th>&nbsp;&nbsp;&nbsp;&nbsp;
                            <td class="name2" colspan="2">
                                <input name="user_name" value="${loginuser.user_name}" class="name22 user_name_" type="text" placeholder=" 如：absd325" onchange="check1(this)"required/></td>
                            <td class="name3"><span class="user_name_ms text_te"><i class="show_sh"></i>字母开头，允许6-25字节，允许字母数字下划线。</span>
                        </div><br>
                            <div class="con_4_name"><span class="span1">手机号：&nbsp&nbsp&nbsp&nbsp</span><span class="con_4_con con_txt">
                            <input  readonly class="con_name1 mobile_email_" type="text" value="${loginuser.user_phone}"  autocomplete="off"></span>
                            </div><br>
                            <div class="con_4_name"><span class="span1">身份证号：&nbsp</span><span class="con_4_con con_txt">
                            <input id="" class="con_name1 id_number_" name="user_idcard" type="text" value="${loginuser.user_idcard}" autocomplete="off" onchange="check5(this)" required></span>
                                <span class="id_number_ms text_te"><i class="show_sh"></i>请输入正确省身份证号</span>
                            </div><br>

                            <div>
                                <th class="ps1">密码：&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</th>
                                <td class="ps2" colspan="2"><input name="user_pwd" class="ps22 user_ps_" type="password" placeholder=" 密码" onchange="check3(this)" required/></td>
                                <td class="ps3"><span class="user_ps_ms text_te"><i class="show_sh"></i>请输入密码，只能是6到18位数字、下划线、字母组成。</span></td>
                            </div><br>
                            <div>
                                <th class="pss1">确认密码：&nbsp</th>
                                <td class="pss2" colspan="2"><input name="user_password1" class="pss22 user_ps1_" type="password" placeholder=" 确认密码" onchange="check4(this)" required/></td>
                                <td class="pss3"><span class="user_ps1_ms text_te"><i class="show_sh"></i>请重新输入密码<!--密码不一致--></span></td>
                            </div><br>
                        </div>
                        <div>
                            <div class="" height="45"></div>
                            <div class="reg_button" colspan="2">
                                <input class="press_button" type="submit" name="submit" value="更新信息" /></div>
                            </div>
                    </from>
                    <div class="hr_10">
                    </div>

                    <div class="hr_8"></div>
                    <?php } ?>
                </div>
            </div><!--右侧信息完-->
        </div><!--左右侧完-->

    </div><!--整个内容部分-->
    <div class="hr_8"></div>
    <!--底部-->
    <jsp:include page="foot.jsp"></jsp:include>
    <!--底部-->
</div>
</body>
</html>
